﻿/*
 * 
 *	C# object representation of row in 'researchRepo.permissions' table:
 *	
 *	Currently a simple mapping of all table columns to equivalent properties,
 *	though the class might be expanded to track appropriate relationships with other tables.
 *	Or it might be dropped completely since RRFile objects currently track their own permissions.
 * 
 */

namespace ResearchRepository.Models
{
	public class RRPermission
	{
		public RRPermission(int fID, int uID, int pID)
		{
			FileId = fID;
			UserId = uID;
			PermId = pID;
		}
		public RRPermission(RRPermission source)
			:this(source.FileId,
					source.UserId,
					source.PermId)
		{}
		public RRPermission(System.Data.IDataRecord source)
			:this((int) source["fileID"],
					(int) source["userID"],
					(int) source["permID"])
		{}

		// named alias for constructor, provides handle to simulate a function pointer to constructor
		public static RRPermission construct(System.Data.IDataRecord source)
		{
			return new RRPermission(source);
		}

		public int FileId { get; set; }
		public int UserId { get; set; }
		public int PermId { get; set; }
	}
}